package com.aaa.marketresearch.dataresource.service;

import com.aaa.marketresearch.dataresource.dao.GoodsDAO;
import com.aaa.marketresearch.dataresource.domain.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Nail
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsDAO goodsDAO;

    @Override
    public List<Goods> getAll() {
        return this.goodsDAO.getAll();
    }

    @Override
    public List<Goods> getWithPartNameLike(String partName) {
        return goodsDAO.getWithPartNameLike(partName);
    }

    @Override
    public Goods getById(Integer id) {
        return this.goodsDAO.getById(id);
    }

    @Override
    public Goods getByBarcode(Long barcode) {
        return goodsDAO.getByBarcode(barcode);
    }

    @Transactional
    @Override
    public void save(Goods goods) {
        this.goodsDAO.save(goods);
    }

    @Transactional
    @Override
    public boolean delete(Integer id) {
        return goodsDAO.delete(id);
    }
}
